﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.IO;
using System.Drawing.Drawing2D;
using 学院学生管理系统;

namespace WindowsFormsApplication1
{
    public partial class 出入登记 : Form
    {
        public 出入登记()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
             string t;
            OleDbConnection a1 = new OleDbConnection();
            OleDbCommand a2 = new OleDbCommand();
            a1.ConnectionString = Class1.mas;
            a1.Open();

            t = "select * from 出入登记 where 日期='" + textBox1.Text.Trim() + "'";
            a2.CommandText = t;
            a2.Connection = a1;
            OleDbDataReader a3 = a2.ExecuteReader();
            if (a3.Read())
            {
                MessageBox.Show("信息已经存在！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            else
            {
                a3.Close();
                string y;
                y = "insert into 出入登记 values(" + "'" + textBox1.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox3.Text.Trim() + "')";
                if (textBox1.Text == "" || textBox5.Text == "" || textBox2.Text == "" || textBox4.Text == "" || textBox3.Text == "")
                {
                    MessageBox.Show("信息不能为空！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    a2.CommandText = y;
                    a2.Connection = a1;
                    a2.ExecuteNonQuery();
                    MessageBox.Show("信息提交成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }
        }
    }
}
    
    
